﻿using System;
using System.Collections.Generic;
using System.Text;
using Slf;

namespace Loggers_Writing_Different_Files
{
  class Program
  {
    static void Main(string[] args)
    {
      Console.ForegroundColor = ConsoleColor.Green;
      Console.Out.WriteLine("App.config was configured to write to two different files:\n");
      Console.Out.WriteLine("  - log-common.txt (output of default logger)");
      Console.Out.WriteLine("  - log-data-access.txt (output of named logger)");
      Console.ResetColor();


      //get the default logger
      ILogger logger = LoggerService.GetLogger();
      logger.Info("This info is written to the default log file.");

      //get the named logger
      logger = LoggerService.GetLogger("Com.Foo.DataAccess");
      logger.Warn("This warning is written to the data-access log file.");

      //get the named logger
      logger = LoggerService.GetLogger("Com.Foo.DataAccess.Client");
      logger.Warn("This warning is also written to the data-access log file due to the hierarchic of logger names");

      //get the named logger
      logger = LoggerService.GetLogger("Com.Foo.DataAccess");
      logger.Debug("This message is not written to the data-access log because of the level filter in the configuration");

         
      Console.ReadLine();
    }
  }
}
